package comp
{
	import spark.components.TextInput;
	import spark.formatters.NumberFormatter;
	
	public class numTextInput extends TextInput
	{
		[Bindable] private var _dataValue:String;
		private var numberFormatter:NumberFormatter; 
		public function numTextInput()
		{
			
			super();						
			numberFormatter = new NumberFormatter();
			numberFormatter.trailingZeros = false;
			//numberFormatter.leadingZero = false; 
			this.setStyle("textAlign", "right");
					
		}
		
		public function get dataValue():String{
			var re:RegExp = new RegExp(",", "g");
			var iReturn:String =  this.text.replace(re,"");
			if(iReturn==null || iReturn==''){
				iReturn = '0';
			}
			_dataValue = iReturn;				
			return _dataValue; 
		}
		
		public function set dataValue(val:String):void{
			var re:RegExp = new RegExp(",", "g");
			val = val.replace(re,"");
			
			if(isNaN(Number(val))) {
				this.text = "0"
			}
			else {
				this.text = numberFormatter.format(val);//NumberUtil.NumberFormat(Number(val))
			}
		}
	}
}